<?xml version="1.0" encoding="utf-8"?>
<html xmlns:str="http://exslt.org/strings"><head><title>duetopia - Documentation - OpenSearch</title><link rel="stylesheet" href="docs.css"/></head><body><div class="menu"><h3>Setup</h3><p><a href="installation.html">Installation</a><br/><a href="configuration.html">Configuration</a></p><h4>Customisation</h4><p><a href="custom_classes.html">Custom Classes</a></p><h3>Interfaces</h3><p><a href="api.html">Quick API Guide</a><br/><a href="opensearch.html">Opensearch Guide</a><br/><a href="opensearch_client.html">Opensearch Client</a></p></div><div id="header">
<h1>duetopia</h1>

</div><div id="content">
<h2>Installation</h2>

<div id="cmenu">
<ul>
<li><a href="#postgis">Setting up PostGIS</a></li>
<li><a href="#geodjango">Installing GeoDjango</a></li>
<li><a href="#configuration">Configuring Database + Server</a></li>
<li><a href="#lighttpd">Lighttpd webserver setup</a></li>
<li><a href="#apache">Apache/mod_python webserver setup </a></li>
</ul>
</div>

<h3>Package Installation</h3>

<p>
Get the latest release via googlecode:

<a href="http://duetopia.googlecode.com/files/duetopia-0.1.tar.gz">http://duetopia.googlecode.com/files/duetopia-0.1.tar.gz</a><br/>

Or by checking out this package from the svn repository (<a href="http://code.google.com/p/duetopia/source/checkout">http://code.google.com/p/duetopia/source/checkout</a> - <tt>svn/trunk/dist/duetopia-0.1.tar.gz</tt>.
</p>
<p>
In either of the above cases:

<pre>

        $ <b>gunzip duetopia-0.1.tar.gz; tar -xvf duetopia-0.1.tar</b>
        0.1/duetopia-rdf-0.1.tar.gz
        0.1/duetopia-thredds-0.1.tar.gz
        0.1/duetopia-iso19139-0.1.tar.gz
        # ... various more modules ...
        0.1/install.py
        $ <b>sudo python install.py</b>

</pre>


But wait! Make sure you have the dependencies (principally the postgres and redland storages) installed before carrying out this stage. This script should prompt to auto-install python-based dependencies.
</p>
<p>
Alternatively just check out the whole <tt>trunk</tt> to get the latest working version of the code.

<pre>
        $ <b>svn checkout https://duetopia.googlecode.com/svn/trunk/ duetopia</b>
        $ <b>cd duetopia</b>
        $ <b>duetopia -p</b>
        # prints out a PYTHONPATH for local use
        $ <b>duetopia -i</b>
        # attempts to install the packages. 
</pre>

(Later on there will be a composite package on pypi the python package repository, installable via setuptools ("easy_install duetopia") but this needs a little thinking about.)

<h3>Dependencies</h3>

<pre>
/// ubuntu / debian / Sun VirtualBox ubuntu instance:

	apt-get install redland-utils
	apt-get install postgresql-client-common
	apt-get install postgresql-client-8.3
        
        # These may be installed by the package installer
        apt-get install python-libxml2
        apt-get install python-psycopg2
        apt-get install python-simplejson
    
/// install darwin ports for running postgis on Mac OSX 
/// database server can run on root host or (better) on 
/// another host altogether

	sudo port selfupdate
	sudo port install postgis
	sudo port install postgresql83-server
</pre>

<a name="postgis"/>
<h3>Postgres / PostGIS configuration</h3>

<h4>A from scratch install on Mac OSX</h4>

<a name="OSX"/>
<pre>
/// we need users and groups

	dscl /Local/Default -create /Users/postgres
	dscl /Local/Default -create /Users/postgres UserShell /bin/bash
	dscl /Local/Default -create /Users/postgres RealName PostgreSQL Admin
	dscl /Local/Default -create /Users/postgres UniqueID 100
	dscl /Local/Default -create /Users/postgres PrimaryGroupID 100
	dscl /Local/Default -create /Users/postgres NFSHomeDirectory /opt/local/var/postgres
	dscl /Local/Default -create /Groups/postgres
	dscl /Local/Default -create /Groups/postgres UniqueID 100

	mkdir -p /opt/local/var/postgres/data
	cat &gt; /opt/local/var/postgres/.bashrc &lt;&lt;EOF
. /etc/bashrc
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
EOF


	chown -R postgres:postgres /opt/local/var/postgres
	chmod 700 /opt/local/var/postgres

	# edit /opt/local/etc/LaunchDaemons/org.macports.postgresql83-server/postgresql83-server.wrapper
	# for paths and...
	launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist

	su - postgres -c "/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/postgres/data"
	/opt/local/etc/LaunchDaemons/org.macports.postgresql83-server/postgresql83-server.wrapper start

</pre>
<a name="database"/>
<h4>Database creation</h4>
<p>An install from debian/ubuntu apt should have done the initial postgres setup and inititation and allow you to begin at:</p>
<pre>
        $ sudo su - postgres
        
	## now as postgres user:
	$ psql83
	CREATE USER envisat;
	CREATE DATABASE envisat;
	\c envisat
	CREATE LANGUAGE 'plpgsql';
	\i /opt/local/var/macports/software/postgis/1.3.3_1/opt/local/share/postgis/lwpostgis.sql
	\i /opt/local/var/macports/software/postgis/1.3.3_1/opt/local/share/postgis/spatial_ref_sys.sql
	GRANT ALL ON DATABASE envisat TO envisat;
	GRANT ALL ON spatial_ref_sys TO envisat;
	GRANT ALL ON geometry_columns TO envisat;

    ## insert redland tables into store
    \i duetopia.sql 
    
    ## 

</pre>

<a name="geodjango"/>
<h3>GeoDjango</h3>

<p>GeoDjango was merged to Django's trunk on 5th August 2008. So use the main Django svn checkout.</p>

<ul>
<li><a href="http://geodjango.org/">http://geodjango.org/</a></li>
<li><a href="http://www.djangoproject.com/documentation/install/#installing-the-development-version">http://www.djangoproject.com/documentation/install/#installing-the-development-version</a></li>
<li>
<pre>
    $ svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
    $ cd django-trunk
    $ sudo python setup.py install
</pre></li>
</ul>

<a name="configuration"/>
<h3>Duetopia configuration</h3>
<p>Configuration files are found in the 'config' section of duetopia. The sample configuration is called simply 'app'; you are free to rename it as long as you supply the appropriate DJANGO_SETTINGS_MODULE in your environment. </p>

<p>config/app/settings.py - edit this to supply your database connection info, at a minimum. Also optional override for webserver path, location of static files, etc.</p>

<pre>
    $ export DJANGO_SETTINGS_MODULE=app.settings
    ## edit settings to add database password information, etc

    ## syncdb loads the django models into the database
    $ python manage.py syncdb
    
    ## runserver allows you to test your configuration on localhost.
    ## Very useful for development, as changes to python modules 
    ## are reloaded while the server is still running
    $ python manage.py runserver 

</pre>
<a name="webserver"/>
<a name="lighttpd"/>
<h3>Lighttpd configuration</h3>

<p>The lightweight http server lighttpd is a good way to get running if you don't need to maintain an existing instance of apache.
<p>Configure lighttpd by adding something like the following to                      <tt>/etc/lighttpd/mod_fastcgi.conf</tt>


<pre>

fastcgi.server = (
        "/duetopia.fcgi" => ((
                        "socket" => "/home/jo/terradue/fastcgi.sock",
                        "check-local" => "disable",
        )),
url.rewrite-once = (
        "^(/duetopia/.*)$" => "/duetopia.fcgi$1",
))

</pre>

Start the fast cgi slave process with a script like this
<pre>

        cat > ~/terradue/runfcgi.sh <<EOF
        #!/bin/bash

        cd /home/jo/duetopia/
        export DJANGO_SETTINGS_MODULE=app.settings
        python manage.py runfcgi socket=/home/jo/duetopia/fastcgi.sock pidfile=/home/jo/duetopia/fastcgi.pid
        EOF
        chmod 755 ~/terradue/runfcgi.sh

</pre>

Make sure the permissions on the .sock and .pid files are writable by the webserver.
</p>

<a name="apache"/>
<h3>Apache/mod_python configuration</h3>

<p>
<a href="http://www.djangoproject.com/documentation/modpython/">Django project - How to Use Django with mod_python</a>

<pre>

&lt;Location "/duetopia/register"&gt;
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE app.settings
    PythonOption django.root "" 
    PythonDebug On
&lt;/Location&gt;

</pre>
</p>

<div id="footer"><p><a href="introduction.html">Introduction / Index</a> | <a href="http://duetopia.googlecode.com/">Code Repository</a></p><p><a href="http://www.terradue.com/duetopia/"><img src="img/terradue_logo.jpg" border="0"/></a></p></div></div></body></html>
